package com.example.bzh.gamecat;

import android.app.Application;
import android.content.Intent;

import java.util.List;

import cn.jpush.android.api.JPushInterface;

/**
 * Created by peter on 2016/8/16.
 */
public class MyApp extends Application {

    private static boolean flag = false;
    private static MyApp app;

    private MyApp() {
    }

    public interface onFlagChangedListener {
        void onFlagChanged(boolean flag);
    }

    private onFlagChangedListener listener;

    public void setonFlagChangedListener(onFlagChangedListener listener) {
        this.listener = listener;
    }

    public static boolean getFlag() {
        return flag;
    }

    public static void setFlag(boolean flag) {
        MyApp.flag = flag;
    }

    public static MyApp getSingleton() {
        if (app == null) {
            synchronized (MyApp.class) {
                if (app == null) {
                    app = new MyApp();
                }
            }
        }
        return app;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        JPushInterface.setDebugMode(true);
        JPushInterface.init(this);
        if (flag) {
            Intent intent = new Intent();
            intent.setAction("true");
            sendBroadcast(intent);
        }
    }
}
